import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import Login from "../views/Login.vue";
import Echarts from "../components/Echarts.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login"
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
    meta: {
      title: "首页"
    },
    children: [
      {
        path: '/',
        redirect: '/home/echarts'
      },
      {
        path: "/home/echarts",
        name: "Echarts",
        component: Echarts,
      },
      {
        path: "/home/kucun",
        name: "KunCun",
        component: () =>
          import("../components/KuCun/KunCun.vue"),
        redirect:'/home/kucun/inku',
        children:[
          {
            path: '/home/kucun/inku',
            name: 'InKu',
            component: () => import('../components/KuCun/InKu/InKu.vue'),
            redirect:'/home/kucun/inku/caigou',
            children:[
              {
                path: "/home/kucun/inku/caigou",
                name: "KunCun",
                component: () =>
                  import("../components/KuCun/InKu/caigou.vue"),
                  meta: {
                    title: "采购入库"
                  },
              },
              {
                path: "/home/kucun/inku/tuichu",
                name: "TuiChu",
                component: () =>
                  import("../components/KuCun/InKu/tuichu.vue"),
                  meta: {
                    title: "采购退货出库"
                  },
              },
              {
                path: "/home/kucun/inku/panying",
                name: "PanYing",
                component: () =>
                  import("../components/KuCun/InKu/PanYing.vue"),
                  meta: {
                    title: "盘盈入库"
                  },
              },
              {
                path: "/home/kucun/inku/zhangku",
                name: "ZhangKu",
                component: () =>
                  import("../components/KuCun/InKu/ZhangKu.vue"),
                  meta: {
                    title: "涨库入库"
                  },
              },
              {
                path: "/home/kucun/inku/qita",
                name: "QiTa",
                component: () =>
                  import("../components/KuCun/InKu/QiTa.vue"),
                  meta: {
                    title: "其他入库"
                  },
              },
            ]
          },
          {
            path: '/home/kucun/outku',
            name: 'OutKu',
            component: () => import('../components/KuCun/OutKu/OutKu.vue'),
            redirect:'/home/kucun/outku/chuku',
            children:[
              {
                path: "/home/kucun/outku/chuku",
                name: "ChuKun",
                component: () =>
                  import("../components/KuCun/OutKu/chuku.vue"),
                  meta: {
                    title: "销售出库"
                  },
              },
              {
                path: "/home/kucun/outku/tuihuoku",
                name: "TuihuoKu",
                component: () =>
                  import("../components/KuCun/OutKu/TuihuoKu.vue"),
                  meta: {
                    title: "销售退货入库"
                  },
              },
              {
                path: "/home/kucun/outku/pankui",
                name: "PanKui",
                component: () =>
                  import("../components/KuCun/OutKu/PanKui.vue"),
                  meta: {
                    title: "盘亏出库"
                  },
              },
              {
                path: "/home/kucun/outku/qita",
                name: "QiTa",
                component: () =>
                  import("../components/KuCun/OutKu/QiTa.vue"),
                  meta: {
                    title: "其他出库"
                  },
              },
            ]
          },
          {
            path: "/home/kucun/tiaobo",
            name: "TiaoBo",
            component: () => import('../components/KuCun/TiaoBo.vue'),
            meta: {
              title: "库存调拨"
            },
          },
          {
            path: "/home/kucun/tiaozheng",
            name: "TiaoZheng",
            component: () => import('../components/KuCun/TiaoZheng.vue'),
            meta: {
              title: "库存调整"
            },
          },
          {
            path: "/home/kucun/pandiam",
            name: "PanDiam",
            component: () => import('../components/KuCun/PanDiam.vue'),
            meta: {
              title: "库存盘点"
            },
          },
          {
            path: "/home/kucun/shisi",
            name: "ShiSi",
            component: () => import('../components/KuCun/ShiSi.vue'),
            meta: {
              title: "实时库存"
            },
          },
        ]
      },
      //往来管理
      {
        path: "/home/wanglai",
        name: "WangLai",
        component: () =>
          import("../components/WangLai/WangLai.vue"),
        redirect:'/home/wanglai/shoukuan',
        children:[
          {
            path: '/home/wanglai/shoukuan',
            name: 'ShouKuan',
            component: () => import('../components/WangLai/ShouKuan/ShouKuan.vue'),
            redirect:'/home/wanglai/shoukuan/yushou',
            children:[
              {
                path: "/home/wanglai/shoukuan/yushou",
                name: "YuShou",
                component: () =>
                  import("../components/WangLai/ShouKuan/YuShou.vue"),
                  meta: {
                    title: "销售预收"
                  },
              },
              {
                path: "/home/wanglai/shoukuan/shoukun",
                name: "ShouKun",
                component: () =>
                  import("../components/WangLai/ShouKuan/ShouKun.vue"),
                  meta: {
                    title: "销售收款"
                  },
              },
              {
                path: "/home/wanglai/shoukuan/qita",
                name: "QiTa",
                component: () =>
                  import("../components/WangLai/ShouKuan/QiTa.vue"),
                  meta: {
                    title: "其他收款"
                  },
              },
            ]
          },
          //采购管理
          {
            path: '/home/wanglai/caigou',
            name: 'CaiGou',
            component: () => import('../components/WangLai/CaiGou/CaiGou.vue'),
            redirect:'/home/wanglai/CaiGou/yushou',
            children:[
              {
                path: "/home/wanglai/CaiGou/yushou",
                name: "YuShou",
                component: () =>
                  import("../components/WangLai/CaiGou/YuShou.vue"),
                  meta: {
                    title: "采购预收"
                  },
              },
              {
                path: "/home/wanglai/CaiGou/fukuan",
                name: "fukuan",
                component: () =>
                  import("../components/WangLai/CaiGou/FuKuan.vue"),
                  meta: {
                    title: "采购付款"
                  },
              },
              {
                path: "/home/wanglai/CaiGou/qita",
                name: "qita",
                component: () =>
                  import("../components/WangLai/CaiGou/QiTa.vue"),
                  meta: {
                    title: "其他付款"
                  },
              },
            ]
          },
          //发票登记
          {
            path: '/home/wanglai/fapiao',
            name: 'FaPiao',
            component: () => import('../components/WangLai/FaPiao/FaPiao.vue'),
            redirect:'/home/wanglai/FaPiao/yushou',
            children:[
              {
                path: "/home/wanglai/FaPiao/yushou",
                name: "YuShou",
                component: () =>
                  import("../components/WangLai/FaPiao/YuShou.vue"),
                  meta: {
                    title: "销售发票"
                  },
              },
              {
                path: "/home/wanglai/FaPiao/fahong",
                name: "fahong",
                component: () =>
                  import("../components/WangLai/FaPiao/FaHong.vue"),
                  meta: {
                    title: "销售发票(红字)"
                  },
              },
              {
                path: "/home/wanglai/FaPiao/caigou",
                name: "caigou",
                component: () =>
                  import("../components/WangLai/FaPiao/CaiGou.vue"),
                  meta: {
                    title: "采购发票"
                  },
              },
              {
                path: "/home/wanglai/FaPiao/caigouhong",
                name: "caicaigouhonggou",
                component: () =>
                  import("../components/WangLai/FaPiao/CaiGouHong.vue"),
                  meta: {
                    title: "采购发票(红字)"
                  },
              },
            ]
          },
          //应收管理
          {
            path: '/home/wanglai/yingshou',
            name: 'YingShou',
            component: () => import('../components/WangLai/YingShou/YingShou.vue'),
            redirect:'/home/wanglai/yingshou/yushou',
            children:[
              {
                path: "/home/wanglai/yingshou/yushou",
                name: "YuShou",
                component: () =>
                  import("../components/WangLai/YingShou/YuShou.vue"),
                  meta: {
                    title: "销售应收"
                  },
              },
              {
                path: "/home/wanglai/yingshou/qita",
                name: "qita",
                component: () =>
                  import("../components/WangLai/YingShou/QiTa.vue"),
                  meta: {
                    title: "其他应收"
                  },
              },
              {
                path: "/home/wanglai/yingshou/heshi",
                name: "heshi",
                component: () =>
                  import("../components/WangLai/YingShou/HeShi.vue"),
                  meta: {
                    title: "收款核应收"
                  },
              },

            ]
          },
          //财务统计
          {
            path: '/home/wanglai/caiwu',
            name: 'CaiWu',
            component: () => import('../components/WangLai/CaiWu/CaiWu.vue'),
            redirect:'/home/wanglai/caiwu/yushou',
            children:[
              {
                path: "/home/wanglai/caiwu/yushou",
                name: "YuShou",
                component: () =>
                  import("../components/WangLai/CaiWu/YuShou.vue"),
                  meta: {
                    title: "商品毛利"
                  },
              },
            ]
          },



          
          {
            path: "/home/wanglai/jieshou",
            name: "JieShou",
            component: () => import('../components/WangLai/JieShou.vue'),
            meta: {
              title: "月末结转"
            },
          },
        ]
      },

      //基础数据
      {
        path: "/home/jichu",
        name: "JiChu",
        component: () =>
          import("../components/JiChu/JiChu.vue"),
          redirect:'/home/jichu/kehu',
        children:[
          {
            path: '/home/jichu/kehu',
            name: 'KeHu',
            component: () => import('../components/JiChu/KeHu.vue'),
            meta: {
              title: '客户'
            }
          },
          {
            path: '/home/jichu/gongyingcang',
            name: 'gongyingcang',
            component: () => import('../components/JiChu/GongYingCang.vue'),
            meta: {
              title: '供应仓'
            }
          },
          {
            path: '/home/jichu/cangku',
            name: 'cangku',
            component: () => import('../components/JiChu/CangKu.vue'),
            meta: {
              title: '仓库'
            }
          },
          {
            path: '/home/jichu/wuliaoF',
            name: 'wuliaoF',
            component: () => import('../components/JiChu/WuLiaoF.vue'),
            meta: {
              title: '物料分类'
            }
          },
          {
            path: '/home/jichu/wuliao',
            name: 'wuliao',
            component: () => import('../components/JiChu/WuLiao.vue'),
            meta: {
              title: '物料'
            }
          },
          {
            path: '/home/jichu/jiliang',
            name: 'jiliang',
            component: () => import('../components/JiChu/JiLiang.vue'),
            meta: {
              title: '计量'
            }
          },
          {
            path: '/home/jichu/bi',
            name: 'bi',
            component: () => import('../components/JiChu/Bi.vue'),
            meta: {
              title: '币种'
            }
          },
          {
            path: '/home/jichu/yinhang',
            name: 'yinhang',
            component: () => import('../components/JiChu/YinHang.vue'),
            meta: {
              title: '银行'
            }
          },
        ]
      },



      //系统管理
      {
        path: "/home/xitong",
        name: "XiTong",
        component: () =>
          import("../components/XiTong/XiTong.vue"),
          redirect:'/home/xitong/yonghu',
        children:[
          {
            path: '/home/xitong/yonghu',
            name: 'yonghu',
            component: () => import('../components/XiTong/YongHu.vue'),
            meta: {
              title: '用户管理'
            }
          },
         
          {
            path: '/home/xitong/juese',
            name: 'juese',
            component: () => import('../components/XiTong/JueSe.vue'),
            meta: {
              title: '角色管理'
            }
          },
          {
            path: '/home/xitong/caidan',
            name: 'caidan',
            component: () => import('../components/XiTong/CaiDan.vue'),
            meta: {
              title: '菜单管理'
            }
          },
          {
            path: '/home/xitong/bumen',
            name: 'bumen',
            component: () => import('../components/XiTong/BuMen.vue'),
            meta: {
              title: '部门管理'
            }
          },
          {
            path: '/home/xitong/jueyong',
            name: 'jueyong',
            component: () => import('../components/XiTong/JueYong.vue'),
            meta: {
              title: '角色用户'
            }
          },
          {
            path: '/home/xitong/bianma',
            name: 'bianma',
            component: () => import('../components/XiTong/BianMa.vue'),
            meta: {
              title: '编码校验规则'
            }
          },
          {
            path: '/home/xitong/zidian',
            name: 'zidian',
            component: () => import('../components/XiTong/ZiDian.vue'),
            meta: {
              title: '数据字典'
            }
          },
          {
            path: '/home/xitong/zhiwu',
            name: 'zhiwu',
            component: () => import('../components/XiTong/ZhiWu.vue'),
            meta: {
              title: '职务管理'
            }
          },
          {
            path: '/home/xitong/bumenwo',
            name: 'bumenwo',
            component: () => import('../components/XiTong/BuMenWo.vue'),
            meta: {
              title: '我的部门'
            }
          },
          {
            path: '/home/xitong/tongxun',
            name: 'tongxun',
            component: () => import('../components/XiTong/TongXun.vue'),
            meta: {
              title: '通讯录'
            }
          },
          {
            path: '/home/xitong/duoshuju',
            name: 'duoshuju',
            component: () => import('../components/XiTong/DuoShuJu.vue'),
            meta: {
              title: '多数据源管理'
            }
          },
          {
            path: '/home/xitong/fenlei',
            name: 'fenlei',
            component: () => import('../components/XiTong/FenLei.vue'),
            meta: {
              title: '分类字典'
            }
          },
          {
            path: '/home/xitong/tonggao',
            name: 'tonggao',
            component: () => import('../components/XiTong/TongGao.vue'),
            meta: {
              title: '系统通告'
            }
          },
        ]
      },


                  //消息中心
                  {
                    path: "/home/xiaoxi",
                    name: "XiaoXi",
                    component: () =>
                      import("../components/XiaoXi/XiaoXi.vue"),
                      redirect:'/home/xiaoxi/guanli',
                    children:[
                      {
                        path: '/home/xiaoxi/guanli',
                        name: 'guanli',
                        component: () => import('../components/XiaoXi/GuanLi.vue'),
                        meta: {
                          title: '消息管理'
                        }
                      },
                     
                      {
                        path: '/home/xiaoxi/muban',
                        name: 'muban',
                        component: () => import('../components/XiaoXi/MuBan.vue'),
                        meta: {
                          title: '模板管理'
                        }
                      },
                    ]
                  },

















































      
      {
        path: "/home/assignment",
        name: "AssignMent",
        component: () =>
          import("../components/AssignMent.vue"),
        meta: {
          title: "任务管理"
        },
      },
      {
        path: "/home/project",
        name: "Project",
        component: () =>
          import("../components/Project.vue"),
        meta: {
          title: "项目管理"
        },
      },
      {
        path: "/home/sampleCollect",
        name: "SampleCollect",
        component: () =>
          import("../components/SampleCollect.vue"),
        meta: {
          title: "样本采集"
        },
      },
      {
        path: "/home/sampleput",
        name: "SamplePut",
        component: () =>
          import("../components/SamplePut.vue"),
        meta: {
          title: "样本入库"
        },
      },
      {
        path: "/home/memory",
        name: "SampleMemory",
        component: () =>
          import("../components/SampleMemory.vue"),
        meta: {
          title: "样本存储"
        },
      },
      {
        path: "/home/memorychild",
        name: "MemoryChild",
        component: () =>
          import("../components/MemoryChild/MemoryChild.vue"),
          redirect:'/home/memorychild/rouchild',
        children:[
          {
            path: '/home/memorychild/rouchild',
            name: 'RouChild',
            component: () => import('../components/MemoryChild/RouChild.vue'),
            meta: {
              title: '容器组管理'
            }
          },
          {
            path: '/home/memorychild/jiachild',
            name: 'RouChild',
            component: () => import('../components/MemoryChild/JiaChild.vue'),
            meta: {
              title: '冻存架（分区）管理'
            }
          },
          {
            path: '/home/memorychild/hechild',
            name: 'RouChild',
            component: () => import('../components/MemoryChild/HeChild.vue'),
            meta: {
              title: '冻存盒管理'
            }
          },
        ]
      },
      {
        path: "/home/basics",
        name: "Basics",
        component: () =>
          import("../components/Basics/Basics.vue"),
          redirect:'/home/basics/sampletype',
        children:[
          {
            path: '/home/basics/sampletype',
            name: 'SampleType',
            component: () => import('../components/Basics/SampleType.vue'),
            meta: {
              title: '样本类型'
            }
          },
          {
            path: '/home/basics/model',
            name: 'Model',
            component: () => import('../components/Basics/Model.vue'),
            meta: {
              title: '冰箱型号'
            }
          },
          {
            path: '/home/basics/shelf',
            name: 'Shelf',
            component: () => import('../components/Basics/Shelf.vue'),
            meta: {
              title: '冻存架型号'
            }
          },
          {
            path: '/home/basics/boxs',
            name: 'Boxs',
            component: () => import('../components/Basics/Boxs.vue'),
            meta: {
              title: '冻存盒型号'
            }
          },
          {
            path: '/home/basics/dictionaries',
            name: 'Dictionaries',
            component: () => import('../components/Basics/Dictionaries.vue'),
            meta: {
              title: '数据字典'
            }
          },
          {
            path: '/home/basics/detail',
            name: 'Detail',
            component: () => import('../components/Basics/Detail.vue'),
            meta: {
              title: '明细管理'
            }
          },
        ]
      },
      {
        path: "/home/samplesource",
        name: "SampleSource",
        component: () =>
          import("../components/SampleSource/SampleSource.vue"),
          redirect:'/home/samplesource/family',
        children:[
          {
            path: '/home/samplesource/family',
            name: 'Family',
            component: () => import('../components/SampleSource/Family.vue'),
            meta: {
              title: '家系管理'
            }
          },
          {
            path: '/home/samplesource/rootin',
            name: 'RootIn',
            component: () => import('../components/SampleSource/RootIn.vue'),
            meta: {
              title: '样本来源'
            }
          },
          {
            path: '/home/samplesource/plan',
            name: 'Plan',
            component: () => import('../components/SampleSource/Plan.vue'),
            meta: {
              title: '随访计划'
            }
          },
          {
            path: '/home/samplesource/record',
            name: 'Record',
            component: () => import('../components/SampleSource/Record.vue'),
            meta: {
              title: '随访记录'
            }
          },
        ]
      },
      {
        path: "/home/system",
        name: "System",
        component: () =>
          import("../components/System/System.vue"),
          redirect:'/home/samplesource/manager',
        children:[
          {
            path: '/home/system/manager',
            name: 'Manager',
            component: () => import('../components/System/Manager.vue'),
            meta: {
              title: '管理员列表'
            }
          },
          {
            path: '/home/system/role',
            name: 'Role',
            component: () => import('../components/System/Role.vue'),
            meta: {
              title: '角色管理'
            }
          },
          {
            path: '/home/system/menu',
            name: 'Menu',
            component: () => import('../components/System/Menu.vue'),
            meta: {
              title: '菜单管理'
            }
          },
          {
            path: '/home/system/test',
            name: 'Test',
            component: () => import('../components/System/Test.vue'),
            meta: {
              title: '测试'
            }
          },
        ]
      },
      {
        path: "/home/skin",
        name: "Skin",
        component: () =>
          import("../components/Skin.vue"),
      },
    ]
  },

  {
    path: "/about",
    name: "About",
    component: () =>
      import("../views/About.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

// // 路由导航守卫 防止用户恶意访问
router.beforeEach((to,from,next)=>{
  //如果去登录 放行
  if(to.path == '/login') return next()
  //验证有没有登录
  let token = sessionStorage.token;
  if (!token) return next('/login');//没有登录强制跳转到登录
  next(); //登录过 该怎样怎样
})

export default router;
